//
//  ViewController.m
//  masoc
//
//  Created by Eric.Wu on 16/2/26.
//  Copyright © 2016年 Eric.Wu. All rights reserved.
//

#import "ViewController.h"
#import <Masonry.h>
#import <MASConstraintMaker.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIView *topview = [[UIView alloc] init];
    topview.backgroundColor = [UIColor redColor];
    [self.view addSubview:topview];
    
    UIView *left = [[UIView alloc] init];
    left.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:left];
    UIView *right = [[UIView alloc] init];
    right.backgroundColor = [UIColor blackColor];
    [self.view addSubview:right];
    UIView *bottom = [[UIView alloc] init];
    bottom.backgroundColor = [UIColor blackColor];
    
    UIView *center = [[UIView alloc]init];
    center.backgroundColor = [UIColor grayColor];
    [self.view addSubview:center];
//    UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
    
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.view).offset(0);
        
        make.left.equalTo(self.view).offset(10);
        
        make.right.equalTo(self.view).offset(-10);
        
        make.bottom.equalTo(self.view).offset(-700);
    }];
    
    [left mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topview).offset(120);
        make.left.equalTo(self.view).offset(20);
        make.right.equalTo(self.view).offset(-30);
        make.bottom.equalTo(self.view).offset(-100);
    }];
  
    [right mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(left.mas_bottom).offset(10);
        make.left.equalTo(self.view).offset(10);
        make.right.equalTo(self.view).offset(-20);
        make.bottom.equalTo(self.view).offset(0);
    }];
    
    [center mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(left);
//        make.centerY.equalTo(left.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@100);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
